This example demonstrates the use of the µC/USB Device™ Vendor device class for vendor specific bulk transfers between an embedded application on the ADSP-SC589 EZ-Board and a Windows host PC running a WinUSB based host application. Three use-cases are demonstrated:
The first two use-cases and host application will be familiar to customers migrating from VisualDSP++® 5.0, where the host application provides loopback and File I/O over USB. This host application is separate from the Micriµm example. However, all three use-cases utilize the same Windows' driver.
See Section 5 for further details on the operation of these use-cases.
For further information about the configuration and use of the Micriµm Echo example, please refer to Section 6 below and the Micriµm documentation.
topThe example uses the µC/USB Device™ Stack for CrossCore® Embedded Studio (µC/USBD) with the Vendor class. The required settings are provided in the µC/USB Device tab of the system.svc dialog. These represent the baseline configuration for the example application and may require adjustment for any extension of this application.
Please note: the Project options for the example are set to avoid unhelpful warning messages. If you wish to change these settings please perform the following instructions:
µC/USBD requires the use of the µC/OS-III™ Real-Time Kernel for CrossCore® Embedded Studio (µC/OS-III). This example is configured to use a pre-built library file, libucos3.dlb, defined by the "USB Examples' Support component". You will be required to obtain the full µC/OS-III™ Real-Time Kernel for CrossCore® Embedded Studio in order to extend the application to meet your own requirements.
If you have µC/OS-III Product installed you can add it to your project in place of the USB Examples' Support component. Before adding the µC/OS-III component, first remove the USB Examples' Support component from the System Configuration Overview" tab:

ADI_USE_UCOS3_SOURCE
µC/OS-III™ Real-Time Kernel for CrossCore® Embedded Studio 2.6.0 and above defines this variable automatically.
The µC/OS-III settings other than the defaults that are built into libucos3.dlb are:



The requirements of the USB software are as follows:
We recommend using a host PC with a built-in USB 2.0 controller otherwise performance will be greatly reduced. Even USB 2.0 plug-in controllers will show a decrease in performance compared to systems with built-in USB 2.0 controllers.
Please also note that using other USB devices simultaneously may slow down the performance of the example. Shutting down CCES after loading the firmware will allow the device to operate as fast as possible.
No particular switch settings are required on the EZ-Board to run the USB application.
topRemember that if you want to shut down CCES after loading the firmware, ensure that you have performed step 4 beforehand, otherwise CCES will stall the processor on exit and USB communication will not be functional.
top
The same host application uC-USBD-VENDOR\Host\Examples\Windows\VendorBulk\Visual Studio 2010\hostapp.exe is used for both
use-cases; It must be run from a Windows command line. Use the -h switch for a list of
available options. In addition to headline-functions, support is provided for other simple
commands such as dumping memory, filling memory, getting firmware version, etc.
Note, that setting breakpoints in the firmware may cause the host utility to timeout depending on the method used by the host to open a connection with the device. The loopback example uses asynchronous I/O and is capable of timing out while the redirect_IO example uses synchronous I/O and will not time out. If you execute an asynchronous Read() or Write() from the host and hit a breakpoint on the device before completing the transaction you will timeout. Just be sure not to place breakpoints in code that performs the read or write and you should not timeout.
The hostapp and the Vendor bulk device application maintains the following protocol of host initiated transfers
A 12 byte command block is sent down with a command, the data size and an optional 4-byte value
The data phase will either be an IN (device to host) or OUT (host to device) transfer or a combination of both.
For each command given, the hostapp will
The loopback function involves data being send from the host to the device and back again. The host verifies that the data is correct and performs some throughput calculations which it displays to the user. The loopback program flow is as follows:
Running hostapp -l will display a screen - that is continuously updated - such as the
following:
The header information should be self-explanatory, but note that the "Transfer size" will either be constant with -l or -c options and variable with -r option.
The bottom table gives the throughput figures (in Mbytes per second, 1MB = 1024*1024 bytes) in both directions and is detailed as follows:
| LAST: | Gives you the bandwidth for the last transfer. | AVERAGE LAST 100: | Calculates the bandwidth for the last 100 transfers and displays the average rate This is particularly useful for tuning your app. |
| AVERAGE: | This is probably the most useful information that gives you the averge bandwidth during this run. |
| MAX: | The maximum bandwidth achieved during this run. |
| MIN: | The minimum bandwidth achieved during this run. |
| TIMESTAMPS: | Time of best case out, best case in, worst case out, and worst case in. |
The File I/O function allows the device to open files on the host, read and write these files, and redirects stdio from the device to the host window for viewing by the user. The redirect_IO example can be used to allow users to get debug (printf) information from the device faster and even without CCES running. The File I/O program flow is as follows:
HOST SIDE DEVICE SIDE
-----------------------------------------------------------------------------------------
T0) - waits for a command
T1) - establishes communication with device
T2) - sends down command (-u, etc.)
T3) - wait for I/O requests - receives command and starts I/O
T4) - sends I/O request
T5) - receives I/O request and handles it - waits for reply
T6) - sends reply
T7) - waits for next I/O request - receives reply
This example demonstrates File operations as well as STDIO operations between SC589 EZ-Board and a Windows host PC.
All messages from device will be shown with < DEVICE > header in the GREEN color. Similarly all messages from host will be shown with < HOST > header in CYAN color.
All errors will be printed in RED color with respective < DEVICE > and < HOST > headers.
Follow below instructions to run the demo-
uC-USBD-VENDOR\Host\Examples\Windows\VendorBulk\Visual Studio 2010 and type .\hostapp.exe -u command.
< HOST > Start servicing USBIO < DEVICE > This is not an error, but errors will print in red < DEVICE > < DEVICE > What is your name (please don't use spaces)?Now control is waiting for an input from user. This input name will go to the device and will be printed back on the host console. abcd < DEVICE > Ok abcd, how many test lines should I print? (please enter using only characters 0-9 with no spaces) 2 < DEVICE > Test line 1 < DEVICE > Test line 2 < DEVICE > < DEVICE > fopen < DEVICE > Read 0x5a8 bytes from .\data\test.txt < DEVICE > Wrote 0x5a8 bytes to .\data\txt2.txt < DEVICE > < DEVICE > Read 0x325e0 bytes from .\data\bulee.jpg < DEVICE > Wrote 0x325e0 bytes to .\data\jpg2.jpg < DEVICE > < DEVICE > To view the image go to location < DEVICE > ".\data" < DEVICE > with respect to hostapp application and open jpg2.jpg file < HOST > Device terminated USBIO successfullyAs seen above, User has given input name as abcd and number of test lines as 2.
After that device application has openedtest.txtand abulee.jpgfiles located atuC-USBD-VENDOR\Host\Examples\Windows\VendorBulk\Visual Studio 2010\dataon host PC. These files are read by device and then written back to host in the same location with different names (txt2.txtandjpg2.jpg).After device terminated USBIO redirection, you must see "See this back to CCES Console" message in the CCES console. This shows that all STDIO from the device will be printed in the CCES console again. 5.3.1 Details of USBIO redirection usage
This section explains the example files used for USBIO redirection.
- VendorDemo.c:
- It contains main() function which calls following functions:
- BSP_Init() - Initialize board specific settings
- OsInit(&err) - Initialize the RTOS
- adi_initComponents() - Initialize managed drivers and/or services including USB
- App_TaskCreate() - Creates USBIO_TaskStart
- OSStart(&err) - Starts the RTOS
- app_usbio.c:
- It defines a USBIO task module "USBIO_TaskStart" which is created by VendorDemo.c:App_TaskCreate()
- This task pends on a semaphore by calling app_bulktest.c:USBIO_WaitForHost()
- It calls following APIs (defined in libucusbd.dlb) to intialize the stdio service and redirection of STDIN, STDOUT, STDERR and file operations to USB.
adi_stdio_USBD_InitUsb()- Initializing the STDIO service and USB device as STDIOadi_stdio_USBD_RedirectUsb()- Redirecting all streams to USB- After these calls IO operations can be performed over USB.
- Following APIs need to be called after USBIO operation is completed-
adi_stdio_USBD_StopUsb()- Inform host that we are done with USBIOadi_stdio_USBD_CloseUsb(): Closing USB as STDIO service and terminating STDIO service- Returns back control to app_bulktest.c:App_USBD_BulkTestApp for receiving more commands from host by calling app_bulktest.c:USBIO_ReturnControl().
- app_bulktest.c:
- Defines App_USBD_BulkTestApp" task
- It is created inside prebuilt libucusbd.dlb library and waits for command block from host.
- After receiving the command block it responds according to the request of host.
- In demo example, once "hostapp -u" command is received, App_USBD_BulkTestApp task posts the semaphore and wait for signal from app_usbio.c:USBIO_TaskStart task after USBIO operation are done.
- usb_redirect_io.c:
- Defines PerformIO function for demonstrating the IO operations.
5.4 Note
The host application provided in
uC-USBD-VENDOR\Host\Examples\Windows\VendorBulk\Visual Studio 2010\hostapp.exedoes not not build right away. It requires setupapi.lib and winusb.lib libraries and related header files provided by Microsoft to build.All the required libraries and header files are available through Microsoft Windows SDK. This host application requires winusb.h, winusbio.h, setupapi.h, usb.h, usb100.h, usb200.h header files.
5.4 Connection to both USB OTG (USB0) and USB HS(USB1) ports available on the ADSP-SC589 EZ-Board
ADSP-SC589 EZ-Board comes with an additional USB port i.e. USB HS (USB1) port . This port supports Device mode only. VendorDemoSC589 demo example application allows you to use USB HS (USB1) port in following two ways:
USB HS (USB1) port is not supported for any other USB Device or Host class yet.
- You can connect the Host PC with USB HS port instead of USB OTG port. Follow Sections 5 to run the Vendor Bulk Example.
- You can use two host PCs to connect to each of the USB ports and follow Sections 5 to run the Vendor Bulk Example. This time you need to run the Host application on both the Host PCs. It will allow you to use both USB ports simultaneously. Only restriction is you can not run STDIO and File IO redirection operations simultaneously. Even if you try, Host PC which starts the "Hostapp -u" operation later will wait until the other Host PC runnning "Hostapp -u" command is done.
6. Using the Micrium Echo Demo Application
This demo implements a simple protocol allowing the device to echo the data sent by the host. Micrium Echo demo Application doesn't support the USB OTG HS(USB1) port. Please open the µC/USB Device Configuration->µC/USB Device tab of the system.svc dialog and change the "Number of device controllers" to 1.
Vendor device can be configured as follows-
top
- Enabling the Echo Sync demo which demonstrates the synchronous communication on the device side-
- Open the µC/USB Device Configuration->Vendor tab of the system.svc dialog and Tick on the "Enable Micrium application" option inside the "Vendor class application options" section.
- Tick on "Enable synchronous echo" in case it is not already ticked. Make sure that options "Enable asynchronous echo" and "Enable ADI bulk application" are not ticked.
- Build the project, load it and run.
- Run pre-built host executable, EchoSync.exe, located in
uC-USBD-VENDOR\Host\Examples\Windows\VendorEcho\Visual Studio 2010from the Windows command line.- Specify the number of transfers as mentioned in the below image. It will result in the given number of synchronous transfers between device and host.
![]()
- Enabling the Echo Async demo which demonstrates the asynchronous communication on the device side-
- Open the µC/USB Device Configuration->Vendor tab of the system.svc dialog and Tick on the "Enable Micrium application" option inside the "Vendor class application options" section.
- Tick on "Enable asynchronous echo" in case it is not already ticked. Make sure that options "Enable synchronous echo" and "Enable ADI bulk application" are not ticked.
- Build the project, load it and run.
- Run pre-built host executable, EchoAsync.exe, located in
uC-USBD-VENDOR\Host\Examples\Windows\VendorEcho\Visual Studio 2010from the Windows command line.- Specify the number of transfers as mentioned in the below image. It will result in the given number of asynchronous transfers between device and host.
![]()
- Enabling the Echo Sync demo as well as the Echo Async demo which configures the device as a composite device formed with two vendor interfaces.
These two interface will be visible as two different "ADI Vendor Specific USB Device" in the device manager.
- Open the µC/USB Device Configuration->µC/USB Device tab of the system.svc dialog, change "Maximum number of interfaces" and "Maximum number of alternative interfaces" to 4 in the "Interface configuration" section.
- Open the µC/USB Device Configuration->Vendor tab of the system.svc dialog, change "Maximum number of Vendor class instances" to 2 and Tick on the "Enable Micrium application" option inside the "Vendor class application options" section.
- Tick on "Enable synchronous echo" and "Enable asynchronous echo". Make sure that option "Enable ADI bulk application" is not ticked.
- Build the project, load it and run.
- Run pre-built host executable, EchoSync.exe, located in
uC-USBD-VENDOR\Host\Examples\Windows\VendorEcho\Visual Studio 2010from the Windows command line.- Specify the number of transfers as mentioned in the below image. It will result in given number of synchronous transfers between both vendor interfaces and the host.
![]()
- Run pre-built host executable, EchoAsync.exe, located in
uC-USBD-VENDOR\Host\Examples\Windows\VendorEcho\Visual Studio 2010from the Windows command line.- Specify the number of transfers as mentioned in the below image. It will result in the given number of synchronous and asynchronous transfers between both vendor interfaces and the host..
![]()
Note:
µC/USB Device™ Stack for Vendor class does not support the associated interfaces but for some reason (unknown as of now) there might be a case where you observe that "Number of devices attached" is 1 with one default and one associated interface.Please follow the below steps to get the composite device installed correctly
- Open the Device Manager and uninstall the "ADI Vendor Specific USB Device" under under "ADI Development Tools" with "Delete the driver software for this device" ticked.
![]()
- Reset the board. Reload and run the program again. You will see two "Vendor-specfic class" devices in the Device Manager with no driver installed. Right click on the devices and install the driver by browsing to the uC-USBD-VENDOR\Setup\USB_Drivers. Once driver installtion is done for both the devices, you should be able to see two "ADI Vendor Specific USB Device" devices under "ADI Development Tools".